package com.blueheart.music.service.impl;

import com.blueheart.music.mapper.ListSongMapper;
import com.blueheart.music.model.pojo.ListSong;
import com.blueheart.music.service.ListSongService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ListSongServiceImpl implements ListSongService {
    @Autowired
    private ListSongMapper listSongMapper;

    /**
     * 增
     *
     * @param listSong
     * @return
     */
    @Override
    public Boolean addListSong(ListSong listSong) {
        return listSongMapper.insertSelective(listSong) > 0;
    }

    /**
     * 删
     *
     * @param id
     * @return
     */
    @Override
    public Boolean removeListSong(Integer id) {
        return listSongMapper.deleteByPrimaryKey(id) > 0;
    }

    /**
     * 改
     *
     * @param listSong
     * @return
     */
    @Override
    public Boolean reviseListSong(ListSong listSong) {
        return listSongMapper.updateByPrimaryKeySelective(listSong) > 0;
    }

    /**
     * 查询全部
     *
     * @return
     */
    @Override
    public List<ListSong> findAll() {
        return listSongMapper.selectAll();
    }

    /**
     * 通过主键查询
     *
     * @param id
     * @return
     */
    @Override
    public ListSong findById(Integer id) {
        return listSongMapper.selectByPrimaryKey(id);
    }

    /**
     * 通过歌手id查询
     *
     * @param songId
     * @return
     */
    @Override
    public List<ListSong> findBySongId(Integer songId) {
        return listSongMapper.selectBySongId(songId);
    }

    /**
     * 根据歌单id查询歌曲
     *
     * @param songListId
     * @return
     */
    @Override
    public List<ListSong> findBySongListId(Integer songListId) {
        return listSongMapper.selectBySongListId(songListId);
    }
}
